//
//  ZBTransitionMaskView.m
//  ZBSlideMemuManger
//
//  Created by apple on 2018/5/31.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "ZBTransitionMaskView.h"

@implementation ZBTransitionMaskView

static ZBTransitionMaskView *_shareInstance = nil;
static dispatch_once_t _onceToken;
+ (instancetype)shareInstance {
    
    dispatch_once(&_onceToken, ^{
        _shareInstance = [[ZBTransitionMaskView alloc] init];
    });
    return _shareInstance;
}

+ (void)releaseInstance{
    [_shareInstance removeFromSuperview];
    _onceToken = 0;
    _shareInstance = nil;
}

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        self.backgroundColor = [UIColor blackColor];
        self.alpha = 0;
        
        self.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTap)];
        tap.numberOfTapsRequired = 1;
        [self addGestureRecognizer:tap];
        
        UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
        [self addGestureRecognizer:pan];
    }
    return self;
}

- (void)singleTap {
    [[NSNotificationCenter defaultCenter] postNotificationName:ZBSlideMemuSlideeTapNoticationKey object:self];
}

- (void)handleGesture:(UIPanGestureRecognizer *)pan {
    [[NSNotificationCenter defaultCenter] postNotificationName:ZBSlideMemuSlidePanNoticationKey object:pan];
}

// 屏蔽掉touchesbegin的响应链
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { }

@end
